package com.league.zjxn.main.access

import androidx.core.widget.addTextChangedListener
import com.league.zjxn.R
import com.league.zjxn.jetpack.vmodel.AccessViewModel
import com.module.lemlin.owner.OwnerAbstractFragment
import com.module.lemlin.owner.OwnerViewModeFragment
import kotlinx.android.synthetic.main.fragment_access_update_pass.*

class UpdatePassFragment : OwnerViewModeFragment<AccessViewModel>() {

    companion object {
        fun newInstance(): UpdatePassFragment {
            return UpdatePassFragment()
        }
    }

    override fun viewModel(): AccessViewModel {
        return createViewModel(requireActivity())
    }

    override val layoutResId: Int
        get() = R.layout.fragment_access_update_pass

    override fun initView() {

        etUpdatePassPwd.addTextChangedListener { editable ->
            editable?.let { viewModel.mMapUpdatePass["password"] = it.toString() }
            editable?.let { viewModel.mMapUpdatePass["confirm_password"] = it.toString() }
            tvUpdatePassSubmit.isEnabled = !editable.isNullOrEmpty()
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        viewModel.mMapUpdatePass.clear()
    }
}